#include <bits/stdc++.h>
using namespace std;

struct node{
    int d,v,s;
};

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t,n,m,l,V;
    cin>>t;
    while(t--){
        int ans=0;
        cin>>n>>m>>l>>V;
        node a[n];
        set<int> b;
        set<int> b2;
        for(int i=0;i<n;i++)cin>>a[i].d>>a[i].v>>a[i].s;
        for(int i=0;i<m;i++){
            int c;
            cin>>c;
            b.insert(c);
        }
        for(int i=0;i<n;i++){
            for(int j=a[i].d;j<=l;j++){
                if(b.count(j)){
                    double v1;
                    v1 = sqrt(a[i].v*a[i].v+2*a[i].s*(j-a[i].d));
                    if(v1>V){
                        ans++;
                        b2.insert(j);
                        break;
                    }
                    if(v1<=0)break;
                }
            }
        }
        int ans2 = m-b2.size();
        cout<<ans<<" "<<ans2<<endl;
    }
    return 0;
}
